package com.mmy.dao.guide;

import java.util.List;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.mmy.domain.guide.TGuideInfo;

public interface TGuideInfoRepository extends JpaRepository<TGuideInfo, Integer> {
	/* 获取最大导游编号 */
	@Query(value = "select MAX(iGuideID) from tGuideInfo", nativeQuery = true)
	Object getMaxGuideID();

	/* 创建导游信息 */
	@Transactional
	@Modifying
	@Query(value = "INSERT INTO tGuideInfo(iGuideID, cGuideName, cGuideLevel, fPrice, cLanguage, cGuideType, bSex, cIdentity, cGuideCard, cQQ, cWeiXin, cTel, cMail, cTrait, cRaise, cExplain, cPhotoPath, iOrgID, dCreateDate, cCreator, dModifyDate, cReviser, cMemo, cSpare1, cSpare2, cSpare3, cSpare4, cSpare5) VALUES (?1, NULL, NULL, 0, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)", nativeQuery = true)
	void save(int guideID);

	/* 通过ID查询 */
	@Query(value = "select * from tGuideInfo where iGuideID=?1", nativeQuery = true)
	TGuideInfo findByiGuideID(int iGuideID);

	/* 删除 */
	@Transactional
	@Modifying
	@Query(value = "delete from tGuideInfo where iGuideID in (:iGuideIDs)", nativeQuery = true)
	void deleteChecked(@Param("iGuideIDs") List<Integer> iGuideIDs);

}
